/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import baperjakat.ProsesAhp;
import dao.KriteriaDao;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.Kriteria;

/**
 *
 * @author Marlon
 */
public class Main {
    public static void main(String[] args) {
        try {
            testHitungRasioKonsistensi();
        } catch (SQLException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    private static void testMatriksBerpasangan() {
        System.out.println("Test Matriks Perbandingan Berpasangan");
        List<Kriteria> list = new ArrayList<>();
        
        ProsesAhp ahp = new ProsesAhp(list);
        float matriksPerbandinganBerpasangan[][] = ahp.matriksPerbandinganBerpasangan();
        float jumlahMatriksPerbandinganBerpasangan[] = ahp.jumlahMatriksPerbandinganBerpasangan(matriksPerbandinganBerpasangan);
        ahp.cetak(matriksPerbandinganBerpasangan, jumlahMatriksPerbandinganBerpasangan);
    }

    private static void testNilaiKriteria() {
        System.out.println("Test Matriks Nilai Kriteria");
        List<Kriteria> list = new ArrayList<>();
        
        ProsesAhp ahp = new ProsesAhp(list);
        float matriksPerbandinganBerpasangan[][] = ahp.matriksPerbandinganBerpasangan();
        float matriksNilaiKriteria[][] = ahp.matriksNilaiKriteria(matriksPerbandinganBerpasangan);
        float barisPrioritas[] = ahp.barisPrioritas(matriksNilaiKriteria);
        ahp.cetak(matriksNilaiKriteria, barisPrioritas);
    }
    
    private static void testMatriksPenjumlahanSetiapBaris() {
        System.out.println("Test Matriks Penjumlahan Setiap Baris");
        List<Kriteria> list = new ArrayList<>();
        
        ProsesAhp ahp = new ProsesAhp(list);
        float matriksPerbandinganBerpasangan[][] = ahp.matriksPerbandinganBerpasangan();
        float matriksNilaiKriteria[][] = ahp.matriksNilaiKriteria(matriksPerbandinganBerpasangan);
        float barisPrioritas[] = ahp.barisPrioritas(matriksNilaiKriteria);
        float matriksPenjumlahanSetiapBaris[][] = ahp.matriksPenjumlahanSetiapBaris(barisPrioritas, matriksPerbandinganBerpasangan);
        float jumlahMatriksPenjumlahanSetiapBaris[] = ahp.jumlahMatriksPenjumlahanSetiapBaris(matriksPenjumlahanSetiapBaris);

        System.out.println();
        ahp.cetak(matriksPenjumlahanSetiapBaris, jumlahMatriksPenjumlahanSetiapBaris);
    }
    
    private static void testHitungRasioKonsistensi() throws SQLException {
        System.out.println("Test Hitung Rasio Konsistensi");
        List<Kriteria> list = new ArrayList<>();
//        list.add(new Kriteria("1", "1", "Kedisiplinan", "1", "1"));
        
        KriteriaDao dao = new KriteriaDao();
        ProsesAhp ahp = new ProsesAhp(dao.getByJabatan("Kepala Dinas Kesehatan"));
//        ProsesAhp ahp = new ProsesAhp(list);
        float matriksPerbandinganBerpasangan[][] = ahp.matriksPerbandinganBerpasangan();
        float matriksNilaiKriteria[][] = ahp.matriksNilaiKriteria(matriksPerbandinganBerpasangan);
        float barisPrioritas[] = ahp.barisPrioritas(matriksNilaiKriteria);
        float matriksPenjumlahanSetiapBaris[][] = ahp.matriksPenjumlahanSetiapBaris(barisPrioritas, matriksPerbandinganBerpasangan);
        float jumlahMatriksPenjumlahanSetiapBaris[] = ahp.jumlahMatriksPenjumlahanSetiapBaris(matriksPenjumlahanSetiapBaris);
        double rasioKonsistensi = ahp.rasioKonsistensi(jumlahMatriksPenjumlahanSetiapBaris, barisPrioritas);

        System.out.println();
        System.out.println(rasioKonsistensi);
    }
}
